#ifndef __GlPosition_h__
#define __GlPosition_h__

#include <cmath>
#include <iostream>
#include "GlMain.h"

namespace GraphicLibrary
{
	class Position;
	inline Position operator + (const Position &left, const Position &right);
	inline Position operator - (const Position &left, const Position &right);
	inline Position operator * (const Position &left, const float right);

	class GlExport Position
	{
		public:
			float	mX;
			float	mY;
			inline Position()
				: mX(0.0f)
				, mY(0.0f)
			{}
			inline Position(const float x, const float y)
				: mX(x)
				, mY(y)
			{}
			inline Position(const Position &other)
				: mX(other.mX)
				, mY(other.mY)
			{}
			inline float length() const
			{
				return sqrt(mX * mX + mY * mY);
			}
			inline bool operator == (const Position &other) const	{return mX == other.mX && mY == other.mY;}
			inline bool operator != (const Position &other) const	{return !operator == (other);}
			static float Distance(const Position &left, const Position &right)
			{
				return (left - right).length();
			}
	};

	//------------------------------------------------------
	inline Position operator + (const Position &left, const Position &right)
	{
		return Position(left.mX + right.mX, left.mY + right.mY);
	}

	//------------------------------------------------------
	inline Position operator - (const Position &left, const Position &right)
	{
		return Position(left.mX - right.mX, left.mY - right.mY);
	}

	//------------------------------------------------------
	inline Position operator * (const Position &left, const float right)
	{
		return Position(left.mX * right, left.mY * right);
	}

	//------------------------------------------------------
	inline std::ostream& operator << (std::ostream &stream, const Position &pos)
	{
		stream << "Position(" << pos.mX << ": " << pos.mY << ")";
		return stream;
	}
}

#endif // __GlPosition_h__
